/*
 * @Author: taosong 2289713738@qq.com
 * @Date: 2023-12-28 19:32:12
 * @LastEditors: taosong 2289713738@qq.com
 * @LastEditTime: 2023-12-28 20:07:21
 * @FilePath: \ele-h5\src\utils\raf.ts
 * @Description:
 *
 * Copyright (c) 2023 by ${git_name_email}, All Rights Reserved.
 */

export const rAF =
  requestAnimationFrame ||
  function (callback) {
    setTimeout(callback, 1000 / 60)
  }

export const cancelRAF =
  cancelAnimationFrame ||
  function (id: number) {
    clearTimeout(id)
  }

export const doubleRaf = (fn: () => void) => {
  rAF(() => rAF(fn))
}
